package com.aizuda.boot.modules.business.contractName.controller;

import com.aizuda.boot.modules.business.contractName.domain.request.GenerateNameDTO;
import com.aizuda.boot.modules.business.contractName.domain.request.NameRuleSaveDTO;
import com.aizuda.boot.modules.business.contractName.domain.response.ContractNameRuleDetailVO;
import com.aizuda.boot.modules.business.contractName.domain.response.ContractNameRuleListVO;
import com.aizuda.boot.modules.business.contractName.service.ContractNameRuleService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author sangyirong
 * @ClassName ContractNameRuleController
 * @Version 1.0
 * @Date 2025/7/4 16:16
 */
@RestController
@RequestMapping("/contractNameRule")
@Tag(name = "合同名称规则管理接口", description = "合同名称规则管理接口")
public class ContractNameRuleController {

    @Resource
    private ContractNameRuleService contractNameRuleService;

    @Operation(summary = "创建合同名称规则")
    @PostMapping("create")
    public boolean createContractNumberRule(@RequestBody NameRuleSaveDTO dto){
        return contractNameRuleService.create(dto);
    }

    @Operation(summary = "获取合同名称规则列表")
    @GetMapping("list")
    public List<ContractNameRuleListVO> list(){
        return contractNameRuleService.getList();
    }

    @Operation(summary = "获取合同名称规则详情")
    @GetMapping("detail/{ruleId}")
    public ContractNameRuleDetailVO detail(@PathVariable Long ruleId){
        return contractNameRuleService.getDetail(ruleId);
    }

    @Operation(summary = "修改合同名称规则")
    @PutMapping("update")
    public boolean update(@RequestBody NameRuleSaveDTO dto){
        return contractNameRuleService.updateRule(dto);
    }


    @Operation(summary = "删除合同名称规则")
    @DeleteMapping("delete/{ruleId}")
    public boolean delete(@PathVariable Long ruleId){
        return contractNameRuleService.removeRule(ruleId);
    }

    @Operation(summary = "生成合同名称")
    @PostMapping("getContractNumber")
    public String getContractNumber(@RequestBody GenerateNameDTO dto) {
        return contractNameRuleService.getContractName(dto);
    }

}
